package b1.scenes.home.picpane
{
	import b1.conifg.*;
	import b1.controls.basic.*;
	import b1.players.*;
	import b1.utils.*;
	
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.text.*;

	public class PlayerMessage extends Sprite
	{
		public var mouseOverFlag:Boolean;

		public function PlayerMessage(playerInfo:PlayerInfo)
		{
			super();
			var rankInfo:RankConfig = playerInfo.getRankInfo();
			var nextRankInfo:RankConfig = playerInfo.getNextRankInfo();
			var roundRec:RoundRec;
			mouseOverFlag = false;
			roundRec = new RoundRec(215, 120, 0.8, BFont.roundRecColor);
			addChild(roundRec);
			
			//单击跳转
			var helpText:TextField = new TextField();
			helpText.selectable = false;
			helpText.width = roundRec.width;
			helpText.autoSize = TextFieldAutoSize.CENTER;
			var helpTexFormat:TextFormat = new TextFormat("微软雅黑", 15, 0x000000, true);
			helpTexFormat.leftMargin = 5;
			helpTexFormat.rightMargin = 5;
			helpTexFormat.color = 0x008000;
			helpText.defaultTextFormat = helpTexFormat;
			helpText.text = "单击跳转";
			helpText.y = 10;
			addChild(helpText);
			var playerHonourScore:int = 0;
			for (var i:int = 0; i < playerInfo.playerHonour.length; i++)
			{
				if (playerInfo.playerHonour[i])
					playerHonourScore += playerInfo.playerHonour[i];
			}
			var gap:int = 10;
			var rankText:TextField = new TextField();
			rankText.selectable = false;
        	rankText.autoSize = TextFieldAutoSize.LEFT;
        	rankText.width = roundRec.width;
        	rankText.wordWrap = true;
			var texFormat:TextFormat = new TextFormat("微软雅黑", 14, 0x000000);
			texFormat.leftMargin = 5;
			texFormat.rightMargin = 5;
			rankText.defaultTextFormat = texFormat;
			rankText.text = "排名：" + (playerInfo.equipRank + 1) + "\n装备评分：" + playerHonourScore;
			rankText.x = gap;
			rankText.y = 30;
			addChild(rankText);
			var honourCount:int = 0;
			for (i = 0; i < playerInfo.playerHonour.length; i++)
			{
				if (playerInfo.playerHonour[i] > 0)
				{
					var equipHonour:EquipHonour = new EquipHonour(i, playerInfo.playerHonour[i]);
					equipHonour.width = 20;
					equipHonour.height = 20;
					equipHonour.x = 30 * honourCount + 18;
					equipHonour.y = rankText.y + rankText.height + 10;
					this.addChild(equipHonour);
					honourCount++;
				}
			}
			this.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
			this.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
			
		}
		
		private function onMouseOver(event:MouseEvent):void
		{
			this.mouseOverFlag = true;
		}
		
		private function onMouseOut(event:MouseEvent):void
		{
			this.mouseOverFlag = false;
		}
		
	}
}